package com.dhh.activity;

import android.os.*;
import android.util.*;

import java.util.*;

import com.dhh.vo.PlanItem;

public class Data {
	public static final String TAG = Data.class.getSimpleName();
	
	public static List<Pair<String, List<PlanItem>>> getAllData() {
		List<Pair<String, List<PlanItem>>> res = new ArrayList<Pair<String, List<PlanItem>>>();
		
		for (int i = 0; i < 4; i++) {
			res.add(getOneSection(i));
		}
		
		return res;
	}
	
	public static List<PlanItem> getFlattenedData() {
		 List<PlanItem> res = new ArrayList<PlanItem>();
		 
		 for (int i = 0; i < 4; i++) {
			 res.addAll(getOneSection(i).second);
		 }
		 
		 return res;
	}
	
	public static Pair<Boolean, List<PlanItem>> getRows(int page) {
		List<PlanItem> flattenedData = getFlattenedData();
		if (page == 1) {
			return new Pair<Boolean, List<PlanItem>>(true, flattenedData.subList(0, 5));
		} else {
			SystemClock.sleep(2000); // simulate loading
			return new Pair<Boolean, List<PlanItem>>(page * 5 < flattenedData.size(), flattenedData.subList((page - 1) * 5, Math.min(page * 5, flattenedData.size())));
		}
	}
	
	public static Pair<String, List<PlanItem>> getOneSection(int index) {
		String[] titles = {"Breakfast", "Lunch", "Dinner", "Dairy"};
		
		PlanItem[][] items = {
				
		};
		
		return new Pair<String, List<PlanItem>>(titles[index], Arrays.asList(items[index]));
	}
}
